#!/bin/bash

SBCL_CMD=`rospack find sbcl`/scripts/run-sbcl.sh
if [[ $# == 4 ]]; then
  pkg=$1
  system=$2
  entry=$3
  output=$4
  $SBCL_CMD --noinform --end-runtime-options --userinit `rospack find roslisp`/scripts/roslisp-sbcl-init --noprint --disable-debugger --load `rospack find roslisp`/scripts/make-roslisp-exec.lisp $pkg $system $entry $output.lisp || exit $?
  cat > $output <<EOF
#!/bin/bash
ROSLISP_CURRENT_PACKAGE=$pkg \`\rospack find sbcl\`/scripts/run-sbcl.sh --noinform --end-runtime-options --noprint --no-userinit --disable-debugger --load $output.lisp --end-toplevel-options \$*
EOF
  chmod a+x $output
else
    echo "Usage: make_node_exec <pkg> <system> <entry> <output>"
    exit 1
fi
